package com.senmin.aPrinciple.a2LiskovSubstitutionPrinciple.fdemo1;

/**
 * @className: dmeo1
 * @author: xpj
 * @create: 2021/6/19
 * @description:
 */
class dmeo1 {
    public static void main(String[] args) {
        A a =new A();
        System.out.println("11-3="+a.fun1(11,3));
        System.out.println("1-8="+a.fun1(1,8));


        System.out.println("-------------------------------------------");
        B b =new B();
        System.out.println("11-3="+b.fun1(11,3));
        System.out.println("1-8="+b.fun1(1,8));
        System.out.println("11+3+9="+a.fun1(11,3));


    }
}

class A  {
    //返回两个类的差
    public int fun1(int num1, int num2){
        return num1- num2;
    }
}

//B类继承了A
//增加一个新功能，完成了两个数相加，然后和9求和
class B extends A {
    @Override
    //分析：这里无意识重写了父类fun1方法
    public int fun1(int a,int b){
        return a+b;
    }

    public int fun2(int a,int b){
        return fun1(a,b)+9;
    }
}
